<?php
//elegxos gia duplotupo username
function nameCheck()
{
	$tempName=$_POST['username'];
	$result=mysql_query("SELECT * FROM user WHERE username='$tempName'");
	return mysql_numrows($result);
}

function show_regist_info()
{
	echo "<b>Your info:</b>";
	echo "<br>";
	echo "<table border=5>";
	echo "<tr>";
	echo "<td>";
	echo "Last Name";
	echo "</td>";
	echo "<td>";
	echo $_POST["lname"];
	echo "</td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td>";
	echo "First Name";
	echo "</td>";
	echo "<td>";
	echo $_POST["fname"];
	echo "</td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td>";
	echo "Birth Date";
	echo "</td>";
	echo "<td>";
	echo $_POST["date"];
	echo "</td>";
	echo "</tr>";

	echo "<tr>";
	echo "<td>";
	echo "Username";
	echo "</td>";
	echo "<td>";
	echo $_POST["username"];
	echo "</td>";
	echo "</tr>";
	echo "</table>";
	
	echo "<br>";
	echo "If the info is correct click Register";
	echo "<br>";
	echo "else click <a href='register.php'>here </a> to go back";
	echo "<br>";
	echo "<br>";
	echo "<input type='submit' value='Register'>";
}	

//register enos neou user
function regist()
{
	$lname=$_SESSION['lname'];
	$fname=$_SESSION['fname'];
	$date=$_SESSION['date'];
	$username=$_SESSION['username'];
	$password=$_SESSION['password'];
	
	$password=mysql_real_escape_string($password);
	$lname=mysql_real_escape_string($lname);
	$fname=mysql_real_escape_string($fname);
	$username=mysql_real_escape_string($username);
	$date=mysql_real_escape_string($date);
	
	mysql_query("INSERT INTO user (username, password, date_of_birth, last_name, first_name) 
		VALUES ('$username', '$password', '$date', '$lname', '$fname')") or die(mysql_error());
	echo "<div align='center'>";
	echo "Congratulations! Your account has been registered!";
	echo "<br>";
	echo "<a href='home.php'>Click here to return to the home page.</a>";
	echo "</div>";
}

?>